package GUI;

import Control.GestorProcesamiento;
import java.awt.Desktop;
import java.io.File;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Cristian Lopez
 */
public class Resultado extends javax.swing.JFrame
{
    private String criterios[];
    private String alternativas[];
    private GestorProcesamiento gestorProcesamiento;
    private Principal principal;

    /** Creates new form Resultado */
    public Resultado(String criterios[], String alternativas[], GestorProcesamiento gestorProcesamiento, Principal p)
    {
        super("Resultado");
        initComponents();

        this.criterios = criterios;
        this.alternativas = alternativas;
        this.gestorProcesamiento = gestorProcesamiento;
        this.principal = p;
        this.setLocationRelativeTo(null);

        cargarTabla(tDiferencias, criterios, prepararFilasComparacion(), gestorProcesamiento.getMatrizDiferencias());
        cargarTabla(tPreferencias, criterios, prepararFilasComparacion(), gestorProcesamiento.getMatrizFuncionPreferencia());
        cargarTabla(tIntensidades, alternativas, alternativas, gestorProcesamiento.getMatrizIndicePreferencia());

        cargarFlujosSuperacion();

        img_grafo.setText("");
        img_grafo.setIcon(new ImageIcon(gestorProcesamiento.getPathGrafo()));

        btnRetroceder.setEnabled(false);
        /*pnl_contenidoPaso1.setVisible(false);
        pnl_contenidoPaso2.setVisible(false);
        pnl_contenidoPaso3.setVisible(false);
        btn_paso1.setIcon(new ImageIcon("." + File.separator + "res" + File.separator + "mostrar.png"));
        btn_paso1.setToolTipText("Mostrar");
        btn_paso2.setIcon(new ImageIcon("." + File.separator + "res" + File.separator + "mostrar.png"));
        btn_paso2.setToolTipText("Mostrar");
        btn_paso3.setIcon(new ImageIcon("." + File.separator + "res" + File.separator + "mostrar.png"));
        btn_paso3.setToolTipText("Mostrar");*/
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        lbl_mDiferencias = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tDiferencias = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        tPreferencias = new javax.swing.JTable();
        lbl_mPreferencias = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lbl_mIntensidad = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tIntensidades = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        lbl_mFlujosSuperacion = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tFlujosSuperación = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        img_grafo = new javax.swing.JLabel();
        lbl_resultado = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        btnRetroceder = new javax.swing.JButton();
        btnAvanzar = new javax.swing.JButton();
        jButtonVolver = new javax.swing.JButton();
        btnExportar = new javax.swing.JButton();
        jMenuBar = new javax.swing.JMenuBar();
        jMenuAyuda = new javax.swing.JMenu();
        jMenuItemAyuda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("frame_resultado"); // NOI18N

        lbl_mDiferencias.setText("Matriz de Diferencias");

        tDiferencias.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tDiferencias.setEnabled(false);
        tDiferencias.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tDiferencias);

        tPreferencias.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tPreferencias.setEnabled(false);
        tPreferencias.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(tPreferencias);

        lbl_mPreferencias.setText("Matriz de Diferencias con Función de Preferencia");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
                    .addComponent(lbl_mDiferencias)
                    .addComponent(lbl_mPreferencias))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_mDiferencias)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lbl_mPreferencias)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Calcular las Diferencias", jPanel1);

        lbl_mIntensidad.setText("Matriz de Intensidad/Indice de Preferencia");

        tIntensidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tIntensidades.setEnabled(false);
        tIntensidades.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(tIntensidades);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
                    .addComponent(lbl_mIntensidad))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_mIntensidad)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(136, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Calcular Intensidades de Preferencias", jPanel2);

        lbl_mFlujosSuperacion.setText("Flujos de Superación");

        tFlujosSuperación.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(tFlujosSuperación);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
                    .addComponent(lbl_mFlujosSuperacion))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(lbl_mFlujosSuperacion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(179, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Flujos de Superacion", jPanel3);

        img_grafo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        img_grafo.setText("Imagen");
        img_grafo.setToolTipText("");
        img_grafo.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        lbl_resultado.setText("Resultado");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_resultado)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(img_grafo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 629, Short.MAX_VALUE)))
                .addContainerGap(143, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_resultado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(img_grafo, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(96, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Resultado", jPanel4);

        btnRetroceder.setText("<<");
        btnRetroceder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRetrocederActionPerformed(evt);
            }
        });

        btnAvanzar.setText(">>");
        btnAvanzar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAvanzarActionPerformed(evt);
            }
        });

        jButtonVolver.setText("Volver");
        jButtonVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVolverActionPerformed(evt);
            }
        });

        btnExportar.setText("Exportar");
        btnExportar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExportarActionPerformed(evt);
            }
        });

        jMenuAyuda.setText("Ayuda");

        jMenuItemAyuda.setText("Ayuda");
        jMenuItemAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAyudaActionPerformed(evt);
            }
        });
        jMenuAyuda.add(jMenuItemAyuda);

        jMenuBar.add(jMenuAyuda);

        setJMenuBar(jMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 787, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(354, 354, 354)
                        .addComponent(btnRetroceder)
                        .addGap(18, 18, 18)
                        .addComponent(btnAvanzar))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)
                        .addComponent(btnExportar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 390, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRetroceder)
                    .addComponent(btnAvanzar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonVolver)
                    .addComponent(btnExportar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonVolverActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonVolverActionPerformed
    {//GEN-HEADEREND:event_jButtonVolverActionPerformed
        // TODO add your handling code here:
        salir();
    }//GEN-LAST:event_jButtonVolverActionPerformed

    private void btnAvanzarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAvanzarActionPerformed
        switch(jTabbedPane1.getSelectedIndex())
        {
            case 0:
                jTabbedPane1.setSelectedIndex(1);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);
                break;
            case 1:
                jTabbedPane1.setSelectedIndex(2);
                /*btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);*/
                break;
            case 2:
                jTabbedPane1.setSelectedIndex(3);
                btnAvanzar.setEnabled(false);
                //btnRetroceder.setEnabled(true);
                break;
            case 3:
                /*jTabbedPane1.setSelectedIndex(1);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);
                break;*/
        }
    }//GEN-LAST:event_btnAvanzarActionPerformed

    private void btnRetrocederActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRetrocederActionPerformed
        switch(jTabbedPane1.getSelectedIndex())
        {
            case 0:
                /*jTabbedPane1.setSelectedIndex(1);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);
                break;*/
            case 1:
                jTabbedPane1.setSelectedIndex(0);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(false);
                break;
            case 2:
                jTabbedPane1.setSelectedIndex(1);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);
                break;
            case 3:
                jTabbedPane1.setSelectedIndex(2);
                btnAvanzar.setEnabled(true);
                btnRetroceder.setEnabled(true);
                break;
        }
    }//GEN-LAST:event_btnRetrocederActionPerformed

    private void btnExportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarActionPerformed

        Wizard wizard = new Wizard(gestorProcesamiento, criterios, alternativas, this);
        wizard.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnExportarActionPerformed

    private void jMenuItemAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAyudaActionPerformed
        // TODO add your handling code here:
        Desktop escritorio = Desktop.getDesktop();
        try {
            //File archivo = new File("res/Ayuda.chm");
            File archivo = new File("res/index.html");
            escritorio.open(archivo);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "No se pudo abrir el archivo de ayuda", "Error", JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jMenuItemAyudaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAvanzar;
    private javax.swing.JButton btnExportar;
    private javax.swing.JButton btnRetroceder;
    private javax.swing.JLabel img_grafo;
    private javax.swing.JButton jButtonVolver;
    private javax.swing.JMenu jMenuAyuda;
    private javax.swing.JMenuBar jMenuBar;
    private javax.swing.JMenuItem jMenuItemAyuda;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lbl_mDiferencias;
    private javax.swing.JLabel lbl_mFlujosSuperacion;
    private javax.swing.JLabel lbl_mIntensidad;
    private javax.swing.JLabel lbl_mPreferencias;
    private javax.swing.JLabel lbl_resultado;
    private javax.swing.JTable tDiferencias;
    private javax.swing.JTable tFlujosSuperación;
    private javax.swing.JTable tIntensidades;
    private javax.swing.JTable tPreferencias;
    // End of variables declaration//GEN-END:variables

    private void accionPanel(JPanel panel, JButton boton)
    {
        if (panel.isVisible())
        {
            panel.setVisible(false);
            boton.setIcon(new ImageIcon("." + File.separator + "res" + File.separator + "mostrar.png"));
            boton.setToolTipText("Mostrar");
        }
        else
        {
            panel.setVisible(true);
            boton.setIcon(new ImageIcon("." + File.separator + "res" + File.separator + "ocultar.png"));
            boton.setToolTipText("Ocultar");
        }
    }

    private void cargarTabla(JTable tabla, String columnas[], String filas[], double contenido[][])
    {
        DefaultTableModel dTable = new DefaultTableModel();
        tabla.setModel(dTable);

        String col[] = new String[columnas.length + 1];
        col[0] = " ";
        System.arraycopy(columnas, 0, col, 1, columnas.length);
        dTable.setColumnIdentifiers(col);

        for (int i = 0; i < contenido.length; i++)
        {
            Vector<Object> row = new Vector<Object>(contenido[i].length + 1);
            row.add(filas[i]);
            for (int j = 0; j < contenido[i].length; j++)
            {
                row.add(GestorProcesamiento.getDecimal(4, contenido[i][j]));
            }
            dTable.addRow(row);
        }
    }

    private String[] prepararFilasComparacion()
    {
        String filas[] = new String[(alternativas.length * alternativas.length) - alternativas.length];
        int pos = 0;
        for (int i = 0; i < alternativas.length; i++)
        {
            for (int j = 0; j < alternativas.length; j++)
            {
                if (i == j)
                {
                    continue;
                }
                filas[pos] = alternativas[i] + " - " + alternativas[j];
                pos++;
            }
        }
        return filas;
    }

    private void cargarFlujosSuperacion()
    {
        double flujoSuperacion[][] = new double[2][gestorProcesamiento.getFlujoSuperacionPositivo().length];
        for (int i = 0; i < flujoSuperacion.length; i++)
        {
            for (int j = 0; j < flujoSuperacion[0].length; j++)
            {
                if (i == 0)
                {
                    flujoSuperacion[i][j] = gestorProcesamiento.getFlujoSuperacionPositivo()[j];
                }
                if (i == 1)
                {
                    flujoSuperacion[i][j] = gestorProcesamiento.getFlujoSuperacionNegativo()[j];
                }
            }
        }
        cargarTabla(tFlujosSuperación, alternativas, new String[]
                {
                    "Flujo Positivo", "Flujo Negativo"
                }, flujoSuperacion);
    }

    private void salir()
    {
        File dir = new File("." + File.separator + "res" + File.separator + "tmp");
        if (dir.exists())
        {
            File[] archivos = dir.listFiles();
            for(int i = 0; i<archivos.length; i++)
            {
                archivos[i].delete();
            }
            dir.delete();
        }
        principal.setVisible(true);
        this.dispose();
    }
}
